A method and system for petroleum asset identification generation and self-healing management
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 中国石油大学(北京)克拉玛依校区
- Filing Date
- 2026-07-10
- Publication Date
- 2026-08-07
AI Technical Summary
此外,该方案缺乏WorkerID的自动释放与回收机制,实例异常退出后其WorkerID无法归还资源池,复用该ID也缺少时间戳安全校验,难以保障故障恢复后的唯一性
本申请提供的石油资产标识生成与自愈管理方法及系统中,通过使用etcd租约的自动过期与原子事务抢占,实现工作节点标识WorkerID的全自动化生命周期管理,消除人工配置导致的ID冲突风险,并在服务实例宕机或网络分区时实现资源的自动回收与复用;通过构建基于最近续租成功时间与安全裕量的本地发号门控,实现网络抖动下的弹性降级与发号连续性,既保证了极端弱网环境下的业务可用性,又防止了长时间失联后的ID重复生成;通过引入工作节点标识复用时的最后发号时间戳持久化与安全检查,实现跨实例复用时的时间线安全,确保新旧实例使用同一工作节点标识时生成的ID时间戳严格递增,防止历史数据冲突;通过在数据库联合索引、Redis缓存键及布隆过滤器元素使用租户标识,实现多租户数据的物理与逻辑强隔离,满足油气田、管道公司、作业区的多组织在同一平台下的独立管理需求;通过Redis缓存、布隆过滤器及异步事件聚合的三级优化架构,实现数据库读写压力的削减,能够应对高频巡检、扫描及无效查询场景,提升系统吞吐量并降低延迟。
Smart Images

Figure CN122534045A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of petroleum industry information technology, specifically involving a method and system for petroleum asset identification generation and self-healing management. Background Technology
[0002] The oil industry is rapidly evolving from traditional manual ledgers and single-point SCADA systems to digital oilfields, pipeline integrity management, intelligent operation and maintenance of offshore platforms, and digital twins of assets. In this process, companies need to establish unified, stable, and traceable identifiers for massive amounts of oil assets, including wellhead equipment, pumping units, compressors, valves, pipe sections, drilling tools, sensors, and edge gateways. These identifiers must support offline reading scenarios such as on-site nameplates, QR codes, and RFID / NFC tags, and also serve as primary keys for cloud databases, references to digital twin objects, and unique indexes for cross-system data exchange.
[0003] Currently, the generation of petroleum asset identifiers mainly relies on the following existing technologies: The first type is a central database with an auto-incrementing primary key or a central numbering table. All asset registration requests access the central database to obtain the identifier. In oil and gas fields with multiple stations and multiple edge nodes accessing concurrently, the central database can easily become a write bottleneck. When the offshore platform or remote well site is disconnected from the central network, globally traceable identifiers cannot be continuously generated on-site. The second type is UUIDs or random codes. While this type of solution supports offline generation, UUIDs are relatively long, making them inconvenient for on-site nameplates, short QR codes, and manual entry; random codes lack trend-incrementing properties, which is detrimental to database indexing performance; and vendor equipment codes are usually unique within a single system, making cross-platform unification difficult. The third type is a number segment mode, where the central service batch-allocates consecutive numbers to edge nodes. This solution reduces the pressure on the central system, but the consistency handling of number segment allocation, exhaustion switching, abnormal recycling, and offline retransmission is complex, and long-term offline on-site operations may lead to wasted or duplicate number segment allocations.
[0004] The latest static WorkerID generation scheme, Snowflake, generates a 64-bit unique identifier using a timestamp, WorkerID, and sequence number, offering advantages such as high local throughput and a trending increasing pattern. However, this scheme requires each instance to have a unique pre-configured WorkerID. During containerized dynamic scaling, edge gateway hot-swapping, or disaster recovery switching, duplicate or residual configurations can easily lead to WorkerID conflicts, resulting in duplicate identifiers. Furthermore, this scheme lacks an automatic release and recycling mechanism for WorkerIDs. After an instance exits abnormally, its WorkerID cannot be returned to the resource pool, and reusing the ID lacks timestamp security verification, making it difficult to guarantee uniqueness after fault recovery.
[0005] Therefore, there is an urgent need for a method that can achieve automatic preemption, self-healing management, and secure reuse of WorkerIDs in distributed, multi-tenant, and edge weak network environments, and generate short, trend-increasing, and globally unique petroleum asset identifiers. Summary of the Invention
[0006] In a first aspect, embodiments of this application provide a method for generating and self-healing petroleum asset identifiers, comprising the following steps: S1. Obtain the tenant identifier for the current service; S2. After the service instance starts, it requests a lease from the distributed coordination component, and uses an atomic transaction to preempt an idle worker node identifier. It then binds the preempted worker node identifier to the requested lease, thus obtaining the occupied worker node identifier and the corresponding lease identifier. S3. Based on the lease identifier, periodically renew the lease, calculate the local valid expiration time of number issuance according to the lease life and the most recent successful renewal time, and maintain the number issuance gating status according to the valid expiration time of number issuance; S4. When an asset identifier generation request is received, identify the numbering gating status. If the numbering gating status is allowed, use the occupied work node identifier, combined with the current timestamp and sequence number to generate a numerical asset identifier. S5. After associating the numerical asset identifier with the tenant identifier, persist the data and update the Bloom filter and cache simultaneously to complete the storage of the asset master data; S6. When a maintained lease becomes invalid due to active cancellation or expiration, the occupancy record of the corresponding bound work node identifier is automatically deleted, so that this work node identifier re-enters the idle pool for reuse.
[0007] Furthermore, the specific steps of step S1 are as follows: S11. Assign a unique tenant identifier to each logical organization managing petroleum assets and carry the tenant identifier in an authentication token, API request header, or edge gateway certificate. The logical organization includes oil and gas field companies, oil production plants, operating areas, pipeline companies, or offshore platforms. S12. Establish an asset master table in the database. The asset master table shall at least include primary key, tenant identifier, asset identifier code, asset type and lifecycle status fields, and establish a combined unique index on the tenant identifier and asset identifier code. S13. Based on the aforementioned composite unique index, define the cache namespace, Bloom filter storage elements, and asynchronous event aggregation keys to ensure that tenant boundaries remain consistent across the database, cache, filter, and statistics chain. S14. Load configuration parameters when the service starts. The configuration parameters include worker node identifier pool size, lease lifetime (TTL), safety margin (M), Snowflake epoch start time, Redis address, Bloom filter target false positive rate, and event aggregation flushing cycle.
[0008] Furthermore, the specific steps of step S2 are as follows: S21. Let the bit width of the working node identifier be... Then the candidate working node identifier The range of values is ,in It is a preset positive integer; S22. Identify each candidate working node. In the distributed coordination component, an occupancy key is defined. If the occupancy key exists, it means that the corresponding worker node identifier has been occupied. If the occupancy key does not exist, it means that the corresponding worker node identifier is idle. S23. After the service instance starts, it sends a lease request carrying the lease lifetime to the distributed coordination component and obtains a lease identifier; S24. The service instance iterates through the candidate worker node identifier set, and for each candidate worker node identifier... Perform a compare and write operation based on a distributed coordination component transaction: Check if the occupancy key corresponding to this candidate worker node identifier does not exist; If it does not exist, the metadata of the current service instance will be written to this occupancy key, and the occupancy key will be bound to the applied lease, thereby granting the current service instance exclusive use of the current candidate worker node identifier; If it already exists, continue trying the next candidate worker node identifier; S25. After successfully preempting the worker node identifier, the service instance constructs a lease snapshot locally and publishes the lease snapshot to the number issuer in an atomic manner. The lease snapshot includes at least the fields of worker node identifier, lease identifier, lease lifetime, most recent successful renewal time, valid expiration time of number issuance, number issuance gating status, and lease version number.
[0009] Furthermore, the specific steps of step S3 are as follows: S31. After successfully preempting the worker node identifier, start the lease maintenance coroutine and send renewal requests to the distributed coordination component at a preset ratio of the lease life. S32. Whenever a successful response to a lease renewal request is received, record the response arrival time to update the most recent successful lease renewal time in the lease snapshot, and calculate the local valid expiration time of the number issuance according to the following formula: ; in, This is the valid deadline for issuing numbers. This is the latest time that the lease renewal was successfully completed. M is the lease lifetime, M is the safety margin, and satisfies... , This represents the upper bound of the deviation between the local clock and the coordinated time. This is an estimate of the maximum acceptable network or processing latency. S33. The lease maintenance coroutine sets the number gating status to true and updates the local lease snapshot; S34. Monitor the execution result of the renewal request, and perform the following processing based on the comparison between the current local time and the valid expiration time of the number issuance: If a renewal request fails momentarily but the current local time has not exceeded the valid expiration time for issuing new numbers, the service instance enters the lease lifetime degradation window, allowing the issuance of new numbers and continuous retrying of renewal requests. If the current local time reaches or exceeds the valid deadline for issuing numbers, the number issuance gating status will be set to false, and any subsequent number issuance request will return a "not allowed" error. S35. If the distributed coordination component returns an unrecoverable error, the service instance closes the number issuance gate and triggers a re-preemption process; the unrecoverable error includes lease revocation, lease non-existence, or authentication failure.
[0010] Furthermore, the specific steps of step S4 are as follows: S41. After receiving the asset identifier generation request, the business layer of the service instance performs tenant authentication based on the tenant identifier obtained in step S1; the asset identifier generation request includes asset registration, asset tag binding or digital twin object creation request; S42. The number generator obtains a local lease snapshot, checks whether the number generation gating status is allowed and whether the current time is less than the valid expiration time for number generation; If so, proceed to step S43; If not, refuse to generate asset identifiers and return an error; S43. Number dispenser reads monotonic millisecond time. And calculate the numerical asset identifier according to the following formula. :
[0011] in, The preset start time of the era. The bit width for the worker node identifier. For the same millisecond sequence number width, The worker node identifier held by the current instance. An incrementing sequence number within the same millisecond; S44. If the sequence number is incremented within the same millisecond... Achieving the same millisecond sequence number bit width The maximum allowed value The serial number generator will wait until the next millisecond and reset the serial number incremented within the same millisecond. =0; S45. If a local time rollback is detected and the rollback magnitude exceeds a preset threshold, the number issuance gate is closed and the current lease is released, triggering the process of re-seizing the work node identifier. The callback refers to the local time being reversed compared to the time of the most recent number issuance; S46. The generated numerical asset identifier is Base62 encoded into an external asset identifier code.
[0012] Furthermore, the specific steps of step S5 are as follows: S51. Associate the numerical asset identifier with the tenant identifier to generate an asset master data record. The asset master data record also includes the asset type, physical location, equipment manufacturer, commissioning date, lifecycle status, and digital twin object address. S52. Write the asset master data into the persistent asset master table and use a composite unique index to ensure the uniqueness of the tenant identifier; S53. Insert the element formed by concatenating the tenant identifier and the external asset identifier into a Bloom filter; S54. Create a cache key based on a composite unique index, write asset details to the Redis cache, and set the cache expiration time; S55. Output the asset identifier generation event to the asynchronous event aggregator.
[0013] Furthermore, step S6 is detailed as follows: S61. When a service instance exits normally, causing the lease to expire, stop receiving new requests, flush the asynchronous event buffer, call the lease cancellation interface to actively release the lease, and delete the occupied key identified by the corresponding worker node; S62. When a service instance crashes, the host machine goes down, or the network is interrupted for more than a preset time, causing the lease to expire, the service instance stops sending renewal requests, and the distributed coordination component automatically deletes the occupied key of the corresponding worker node after the lease life expires. S63. After the occupancy key is deleted, the corresponding worker node identifier will automatically enter the idle pool, and the remaining normal running service instances will be preempted and reused in the future; S64. After the number issuance gate is closed due to a fault, the background recovery coroutine reconnects to the distributed coordination component according to the backoff strategy, and after the connection is restored, it first confirms whether the original lease is still valid. If effective, restore the renewal request and number issuance gating status, and return to step S3; If this is ineffective, the worker node identifier preemption process in step S2 will be re-executed.
[0014] Furthermore, after preempting the worker node identifier in step S2 and before using this worker node identifier to generate the asset identifier for the first time in step S4, the following worker node identifier reuse timestamp security check step is also included: S71. Each service instance maintains the last issuance timestamp of the currently occupied worker node identifier in memory, and writes the last issuance timestamp to the distributed coordination component or the worker node identifier audit record in the database when its own service instance exits or periodically heartbeats. S72. When a service instance preempts a worker node identifier, before executing the first number issuance, it reads the historical last number issuance timestamp corresponding to this worker node identifier and uses it as the historical value; S73. Compare the local current time of this service instance with the historical value: If the current local time is not greater than the historical value, wait until the current local time is greater than the historical value, or force the logical time to be set to the historical value plus one time unit, so that the new instance B uses the first numbering timestamp of the same worker node identifier. The last timestamp of the number issued is greater than that of the old instance A. .
[0015] Furthermore, after completing the storage of asset master data in step S5, the following asset query optimization and asynchronous event aggregation steps are also included: S81. When an asset code parsing request is received, the tenant identifier is obtained based on the authentication information, a cache is constructed, and the Redis cache is accessed; If the hit occurs, the asset details will be returned immediately and the access event will be recorded. If the target is not hit, proceed to step S82; S82. Based on the estimated asset quantity and target misjudgment rate Calculate the parameters of the Bloom filter and query the Bloom filter; the parameters include the bitmap length m and the number of hash functions k, which respectively satisfy;
[0016] If the Bloom filter determines that the element with the cache key definitely does not exist, it returns a non-existent result and does not access the database; If the Bloom filter determines that the element with the cache key may exist, it queries the composite unique index in the source database and fills the query result back into the Redis cache. S83. The business layer accumulates high-frequency access events into a memory map and determines the mapping key and corresponding key value; The high-frequency access events include asset queries and QR code scanner inspection events; S84. Background flushing coroutine according to preset fixed period Perform atomic swapping: Replace the current memory mapping with an empty mapping, and perform a batch incremental update on each key in the swapped-out mapping snapshot; S85. The write amplification rejection ratio for evaluating asynchronous aggregation effects is determined using the following formula. :
[0017] in, For event arrival rate, The number of unique asset event keys within the time window; the number of database updates after asynchronous aggregation is determined by... The magnitude was reduced to Magnitude; S86. When a service instance exits normally, first call the Drain interface to force flush the asynchronous event buffer, and then release the lease corresponding to the current worker node identifier according to step S61.
[0018] Secondly, embodiments of this application also provide a petroleum asset identification generation and self-healing management system, including: The tenant identifier acquisition module is used to obtain the tenant identifier of the current business. The worker node preemption module is used to apply for a lease from the distributed coordination component after the service instance starts, and to preempt an idle worker node identifier through an atomic transaction. The preempted worker node identifier is then bound to the applied lease to obtain the occupied worker node identifier and the corresponding lease identifier. The lease maintenance module is used to periodically renew leases based on lease identifiers, calculate the local valid expiration time of number issuance based on lease life and the most recent successful renewal time, and maintain the number issuance gating status based on the valid expiration time of number issuance. The identifier generation module is used to identify the numbering gating status when an asset identifier generation request is received. If the numbering gating status is allowed, the module uses the occupied work node identifier, combined with the current timestamp and sequence number, to generate a numerical asset identifier. The storage module is used to persistently store numerical asset identifiers associated with tenant identifiers, and synchronously update the Bloom filter and cache to complete the storage of asset master data. The release module is used to automatically delete the occupancy record of the corresponding bound work node identifier when the maintained lease becomes invalid due to active cancellation or expiration, so that the work node identifier can re-enter the idle pool for reuse.
[0019] As can be seen from the above technical solutions, this application has the following advantages: The petroleum asset identifier generation and self-healing management method and system provided in this application achieves fully automated lifecycle management of WorkerIDs by using automatic expiration of etcd leases and atomic transaction preemption, eliminating the risk of ID conflicts caused by manual configuration, and realizing automatic resource reclamation and reuse when service instances crash or network partitions occur. By constructing a local ID issuance gating based on the most recent successful lease renewal time and safety margin, elastic degradation and ID issuance continuity under network jitter are achieved, ensuring business availability in extreme weak network environments and preventing ID duplication after long-term disconnection. By introducing the last ID issuance time when reusing WorkerIDs, the system achieves further automation. Persistent and secure timestamp-based architecture ensures timeline security during cross-instance reuse, guaranteeing that ID timestamps generated when new and old instances use the same worker node identifier are strictly incremented to prevent historical data conflicts. Tenant identifiers are used in database composite indexes, Redis cache keys, and Bloom filter elements to achieve strong physical and logical isolation of multi-tenant data, meeting the independent management needs of multiple organizations such as oil and gas fields, pipeline companies, and work areas on the same platform. A three-tiered optimized architecture of Redis caching, Bloom filters, and asynchronous event aggregation reduces database read / write pressure, enabling it to handle high-frequency inspections, scans, and invalid query scenarios, improving system throughput and reducing latency. Attached Figure Description
[0020] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating the petroleum asset identification generation and self-healing management method of the present invention.
[0022] Figure 2 This is a timeline diagram of the lifecycle of the worker node identifier based on the etcd lease in this invention.
[0023] Figure 3 This is a flowchart of the petroleum asset identification query and anti-penetration process of the present invention.
[0024] Figure 4 This is a flowchart of the asynchronous asset identification event aggregation process of the present invention.
[0025] Figure 5 This is a schematic diagram of the petroleum asset identification generation and self-healing management system of the present invention. Detailed Implementation
[0026] The various embodiments of this disclosure will be described more fully in the detailed steps of the petroleum asset identification generation and self-healing management method described below. This disclosure may have various embodiments, and adjustments and changes may be made therein. However, it should be understood that there is no intention to limit the various embodiments of this disclosure to the specific embodiments disclosed herein, but rather this disclosure should be understood to cover all adjustments, equivalents, and / or alternatives falling within the spirit and scope of the various embodiments of this disclosure.
[0027] Definitions of terms in this application: Petroleum assets refer to physical objects that need to be identified, tracked, inspected, maintained, or measured during the oil and gas exploration, drilling and completion, oil and gas production, gathering and transportation, long-distance pipelines, offshore platforms, and refining and chemical front-end production processes. These include, but are not limited to, wellhead equipment, pumping units, compressors, valves, pipe sections, flanges, cathodic protection equipment, pigging equipment, drilling tools, downhole tools, sensors, RTUs, edge gateways, offshore platform equipment, and their digital twin objects.
[0028] etcd is a distributed, strongly consistent key-value store system based on the Raft consistency protocol, providing capabilities such as linear consistent read / write, transaction (Txn), lease (Lease), and key watch (Watch). The distributed coordination component in this application is implemented using etcd, which is used to store worker node identifiers, occupied keys, and lease status.
[0029] A Bloom filter is a space-efficient probabilistic set structure used to determine whether a given asset identifier is likely to exist. In this application, the Bloom filter is used to block database penetration requests caused by non-existent asset identifiers, mis-scanned tag identifiers, malicious enumeration of identifiers, and historically invalidated identifiers.
[0030] Edge gateways are computing nodes deployed at well sites, gathering and transportation stations, valve chambers, metering rooms, offshore platforms, or drilling sites. They are responsible for collecting data from on-site equipment, identifying RFID / NFC / QR code tags, temporarily storing offline data, and synchronizing with the cloud-based oil asset platform.
[0031] The lease version number (revision) is an incrementing version identifier assigned by the distributed coordination component for each lease creation or renewal operation. It is used to distinguish the state versions of the same lease at different points in time. The revision value increments whenever a lease is successfully renewed or a state change occurs, and can be used for auditing and conflict detection.
[0032] In this application, the worker node identifier uniformly refers to the technical concept of node number in the Snowflake algorithm, corresponding to the English term WorkerID. In specific implementations, when used as a field name stored in the distributed coordination component, it can be represented as worker_id; in mathematical formulas, w represents the numerical value of the worker node identifier.
[0033] In this application, the numerical asset identifier refers to a 64-bit integer generated by a formula, used for primary key storage in the database and internal reference; the external asset identifier code refers to a short string obtained by Base62 encoding the numerical asset identifier, used for QR codes, RFID tags, inspection APPs, and on-site manual reading; the asset identifier code is a general term for both, and when it appears alone, its specific data type depends on the context, for example, it refers to a numerical value when stored, and an encoded string when displayed.
[0034] This embodiment provides a method for generating and self-healing petroleum asset identifiers. By using the WorkerID identifier of the etcd lease management work node, the automatic allocation and fault self-healing of petroleum asset identifiers can be achieved.
[0035] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] Please see Figure 1 The diagram shows a flowchart of a method for generating and self-healing petroleum asset identifiers in a specific embodiment. The method includes the following steps: S1. Obtain the tenant identifier for the current service; It should be noted that the tenant identifier is used to achieve logical data isolation in scenarios involving multiple oil and gas companies, multiple work areas, and multiple platforms for shared deployment. This step parses the tenant identifier from the authentication token, API request header, or edge gateway certificate, which becomes the basis for all subsequent database operations, cache key construction, Bloom filter elements, and event aggregation keys, ensuring that data from different tenants will not interfere with each other. S2. After the service instance starts, it requests a lease from the distributed coordination component, and uses an atomic transaction to preempt an idle worker node identifier. It then binds the preempted worker node identifier to the requested lease, thus obtaining the occupied worker node identifier and the corresponding lease identifier. It should be noted that this step achieves fully automatic and conflict-free allocation of WorkerIDs by leveraging the atomic transaction capabilities of distributed coordination components (such as etcd). At the same time, it binds WorkerIDs to leases, thus linking the lifecycle of WorkerIDs to the health of service instances. S3. Based on the lease identifier, periodically renew the lease, calculate the local valid expiration time of number issuance according to the lease life and the most recent successful renewal time, and maintain the number issuance gating status according to the valid expiration time of number issuance; It should be noted that this step sets a safety margin M to advance the effective expiration time of number issuance compared to the actual expiration time of the lease, thus reserving a safety buffer for clock skew and network latency. At the same time, the effective expiration time of number issuance is used as the basis for opening and closing the local number issuance gating. Even if the lease renewal fails momentarily before the expiration time, the service instance can still continue to issue numbers within the degradation window. Once the expiration time is exceeded, the number issuance gating is immediately closed to prevent the worker node identifier WorkerID from being duplicated due to the actual expiration of the lease. S4. When an asset identifier generation request is received, identify the numbering gating status. If the numbering gating status is allowed, use the occupied work node identifier, combined with the current timestamp and sequence number to generate a numerical asset identifier. It should be noted that this step ensures that all ID issuance requests must pass the gating check, that is, confirm that the WorkerID is valid and within its validity period; if the ID issuance gating is closed, such as if the service instance has been unable to renew its lease for a long time, the ID issuance will be directly rejected, thus avoiding the generation of potentially duplicate WorkerIDs in an insecure state and protecting the consistency of the underlying data. S5. After associating the numerical asset identifier with the tenant identifier, persist the data and update the Bloom filter and cache simultaneously to complete the storage of the asset master data; It should be noted that during this step, the cache and Bloom filter are updated synchronously to ensure that new assets can be queried immediately; the Bloom filter is used to intercept invalid asset codes, prevent database penetration, and protect the underlying storage. S6. When a maintained lease becomes invalid due to active cancellation or expiration, the occupation record of the corresponding bound work node identifier is automatically deleted, so that this work node identifier can re-enter the idle pool for reuse. It should be noted that this step enables the automatic release of the WorkerID resource, whether the service instance shuts down normally or crashes, so that no manual intervention is required when scaling up or down containerization or replacing edge nodes.
[0037] This embodiment achieves distributed secure generation of petroleum asset identifiers, optimization of high-frequency queries, and anomaly self-healing management by binding the lifecycle of the WorkerID identifier to the lease of the distributed coordination component, and combining multi-tenant isolation and local gating.
[0038] Furthermore, as a refinement and extension of the specific implementation methods described above, and to fully illustrate the specific implementation process in this embodiment, another method for generating and self-healing petroleum asset identifiers is provided. This method includes the following steps: S1. Obtain the tenant identifier for the current service; The specific steps of step S1 are as follows: S11. Assign a unique tenant identifier to each logical organization managing petroleum assets and carry the tenant identifier in an authentication token, API request header, or edge gateway certificate. The logical organization includes oil and gas field companies, oil production plants, operating areas, pipeline companies, or offshore platforms. S12. Create an asset master table in the database. The asset master table shall at least contain the primary key id, tenant_id, asset_code, asset_type, and lifecycle_state fields, and create a composite unique index (tenant_id, asset_code) on the tenant_id and asset_code. It should be noted that the main asset table also includes fields for asset name (asset_name), location, creation time (created_at), and update time (updated_at); the composite unique index (tenant_id, asset_code) can prevent duplicate identifiers within the same tenant. S13. Based on the aforementioned composite unique index, define the cache namespace petro:asset:cache:{tenant_id}:{asset_code}, Bloom filter storage elements, and asynchronous event aggregation key {tenant_id}:{asset_code}:{event_type} to ensure that the tenant boundary remains consistent across the database, cache, filter, and statistics chain; S14. Load configuration parameters when the service starts. The configuration parameters include worker node identifier pool size, lease lifetime (TTL), safety margin (M), Snowflake epoch start time, Redis address, Bloom filter target false positive rate, and event aggregation flushing cycle. It should be noted that Snowflake is a distributed unique identifier generation algorithm that divides a 64-bit integer into a timestamp field, a worker node identifier field, and a sequence number field, and generates a globally unique numerical identifier through local bit operations without the need for coordination by a central node. The Snowflake epoch start time in this application is a custom start timestamp in the Snowflake algorithm, used to calculate the offset of the current time relative to the epoch. S2. After the service instance starts, it requests a lease from the distributed coordination component, and uses an atomic transaction to preempt an idle worker node identifier. It then binds the preempted worker node identifier to the requested lease, thus obtaining the occupied worker node identifier and the corresponding lease identifier. The specific steps of step S2 are as follows: S21. Let the bit width of the working node identifier be... Then the candidate working node identifier The range of values is ,in It is a preset positive integer; For example, preset =10, then the candidate working node identifier The value range is 0-1023; in actual deployment, it can be adjusted according to the cluster size, for example... =8 corresponds to 0-255. =12 corresponds to 0-4095; S22. Identify each candidate working node. Define occupancy keys in the distributed coordination component If the occupancy key exists, it means that the corresponding work node identifier has been occupied; if the occupancy key does not exist, it means that the corresponding work node identifier is free. S23. After the service instance starts, it sends a lease request carrying the lease time-to-live (TTL) to the distributed coordination component and obtains the lease identifier (lease_id). S24. The service instance iterates through the candidate worker node identifier set, and for each candidate worker node identifier... Perform a compare and write operation based on a distributed coordination component transaction: Check if the occupancy key corresponding to this candidate worker node identifier does not exist; If it does not exist, the metadata of the current service instance will be written to this occupancy key, and the occupancy key will be bound to the applied lease, thereby granting the current service instance exclusive use of the current candidate worker node identifier; If it already exists, continue trying the next candidate worker node identifier; It should be noted that the metadata is in JSON format and includes at least the service instance ID, service name, hostname, process ID, tenant service scope, deployment region, edge site number, startup time, worker node identifier acquisition time, lease identifier lease_id, lease time to live (TTL), and software version. S25. After successfully preempting the worker node identifier, the service instance constructs a lease snapshot locally and publishes the lease snapshot to the issuer in an atomic manner. The lease snapshot includes at least the following fields: worker node identifier worker_id, lease identifier lease_id, lease time to live (TTL), last_ack, last_ack, valid_until, valid_until, gating status generate_allowed, and lease version number revision. S3. Based on the lease identifier, periodically renew the lease, calculate the local valid expiration time of number issuance according to the lease life and the most recent successful renewal time, and maintain the number issuance gating status according to the valid expiration time of number issuance; The specific steps of step S3 are as follows: S31. After successfully preempting the worker node identifier, start the lease maintenance coroutine and send renewal requests KeepAlive to the distributed coordination component at a preset proportion (e.g., one-third) of the lease lifetime time (TTL). The preset ratio is preferably one-third, that is, the renewal period = TTL / 3; for example, when TTL = 15 seconds, a renewal request KeepAlive is sent every 5 seconds; this ratio can reduce the coordination request overhead while ensuring the validity of the lease. S32. Whenever a renewal request is received with a successful KeepAlive response, record the response arrival time to update the most recent successful renewal time last_ack in the lease snapshot, and calculate the local valid expiration time valid_until according to the following formula: ; in, M is the lease lifetime, M is the safety margin, and satisfies... , This represents the upper bound of the deviation between the local clock and the coordinated time. This is an estimate of the maximum acceptable network or processing latency. For example, let there be an upper bound on the deviation between the local clock and the coordinated time of etcd. =500ms, maximum network or processing latency estimate. If the time margin is 1000ms, then the safety margin M is 1500ms; if the network environment is poor, the safety margin M can be increased to 2000ms or higher. S33. The lease maintenance coroutine sets the number gating state generate_allowed to true and updates the local lease snapshot; S34. Monitor the execution result of the renewal request KeepAlive, and perform the following processing based on the comparison between the current local time and the valid expiration time valid_until: If the renewal request KeepAlive fails momentarily but the current local time has not exceeded the valid expiration time valid_until, the service instance enters the lease lifetime time (TTL) degradation window, allowing continued issuance of new numbers and continuous retrying of the renewal request KeepAlive. If the current local time reaches or exceeds the valid deadline for issuing numbers, valid_until, the number issuance gating status generate_allowed will be set to false. After that, any number issuance request will return a generation not allowed error. At this time, any number issuance request will return an ErrGenerateNotAllowed error. The upper layer business can temporarily store the asset registration or event record in the local queue or the waiting buffer of the edge gateway, and wait for the worker node identifier to be obtained again before processing. S35. If the distributed coordination component returns an unrecoverable error, the service instance closes the number issuance gate and triggers a re-preemption process; the unrecoverable error includes lease revocation, lease non-existence, or authentication failure. Please see Figure 2 As shown, the complete sequence of events is demonstrated from service instance startup, lease application, CAS atomic transaction preemption of WorkerID, KeepAlive periodic lease renewal, valid_until calculation of the valid expiration time for number issuance, TTL degradation window maintenance, number issuance gating closure until the lease expires and the WorkerID is automatically released. Figure 2 The system deployment is divided into three layers: the oilfield layer corresponds to the edge gateways and identification terminals in the field environment such as well sites, stations, and offshore platforms; the platform service layer corresponds to the asset identification service instances and number generators; and the infrastructure layer corresponds to the distributed coordination components etcd, Redis caching, and persistent storage. S4. When an asset identifier generation request is received, identify the numbering gating status. If the numbering gating status is allowed, use the occupied work node identifier, combined with the current timestamp and sequence number to generate a numerical asset identifier. The specific steps of step S4 are as follows: S41. After receiving the asset identifier generation request, the business layer of the service instance performs tenant authentication based on the tenant identifier obtained in step S1; the asset identifier generation request includes asset registration, asset tag binding or digital twin object creation request; S42. The number generator obtains a local lease snapshot, checks whether the number generation gating status is allowed and whether the current time is less than the valid number generation deadline valid_until; If so, proceed to step S43; If not, refuse to generate asset identifiers and return an error; S43. Number dispenser reads monotonic millisecond time. And calculate the numerical asset identifier according to the following formula. :
[0039] in, The preset start time of the era. The bit width for the worker node identifier. For the same millisecond sequence number width, The worker node identifier held by the current instance. An incrementing sequence number within the same millisecond; For example, the worker node identifier bit width =10, same width as millisecond sequence number =12, Set to 2020-01-01 00:00:00 UTC; the generated 64-bit numeric asset identifier ID shows an increasing trend, making it suitable as a database primary key; S44. If the sequence number is incremented within the same millisecond... Achieving the same millisecond sequence number bit width The maximum allowed value The serial number generator will wait until the next millisecond and reset the serial number incremented within the same millisecond. =0; S45. If a local time rollback is detected and the rollback magnitude exceeds a preset threshold, the number issuance gate is closed and the current lease is released, triggering the process of re-seizing the work node identifier. The callback refers to the local time being reversed compared to the time of the most recent number issuance; S46. The generated numerical asset identifier is Base62 encoded into an external asset identifier code asset_code, wherein the Base62 encoding uses 62 characters from 0 to 9, az, and AZ to represent integers; For example, the maximum value of a 64-bit positive integer is After Base62 encoding, the maximum length is about 11 characters (such as "2gL6cQZ9n7A"), which is suitable for printing on the QR code of the nameplate of oil equipment or RFID tag; S5. After associating the numerical asset identifier with the tenant identifier, persist the data and update the Bloom filter and cache simultaneously to complete the storage of the asset master data; The specific steps of step S5 are as follows: S51. Associate the numerical asset identifier with the tenant identifier to generate an asset master data record. The asset master data record also includes the asset type, physical location, equipment manufacturer, commissioning date, lifecycle status, and digital twin object address. S52. Write the asset master data into the persistent asset master table and use a composite unique index (tenant_id, asset_code) to ensure the uniqueness of the tenant identifier; S53. Insert the element {tenant_id}:{asset_code}, formed by concatenating the tenant identifier with the Base62 encoded external asset identifier, into a Bloom filter; For example, when the system starts up, it should read existing asset identifiers from the database by tenant and insert them into the Bloom filter in batches to avoid a large number of non-existent queries penetrating the database during the cold start period; S54. Create a cache key petro:asset:cache:{tenant_id}:{asset_code} based on a composite unique index, write the asset details to the Redis cache, and set the cache expiration time; S55. Output the asset identifier generation event to the asynchronous event aggregator; S6. When a maintained lease becomes invalid due to active cancellation or expiration, the occupation record of the corresponding bound work node identifier is automatically deleted, so that this work node identifier can re-enter the idle pool for reuse. The specific steps of step S6 are as follows: S61. When a service instance exits normally, causing the lease to expire, stop receiving new requests, flush the asynchronous event buffer, call the lease cancellation interface to actively release the lease, and delete the occupied key identified by the corresponding worker node; S62. When a service instance crashes, the host machine goes down, or the network is interrupted for more than a preset time, causing the lease to expire, the service instance stops sending renewal requests KeepAlive, and the distributed coordination component automatically deletes the occupied key of the corresponding worker node after the lease lifetime TTL expires. S63. After the occupancy key is deleted, the corresponding worker node identifier will automatically enter the idle pool, and the remaining normal running service instances will be preempted and reused in the future; S64. After the number issuance gate is closed due to a fault, the background recovery coroutine reconnects to the distributed coordination component according to the backoff strategy, and after the connection is restored, it first confirms whether the original lease is still valid. If effective, restore the renewal request KeepAlive and number issuance gating status, and return to step S3; If this is ineffective, the worker node identifier preemption process in step S2 will be re-executed; The backoff strategy refers to the fact that when a service instance closes the number gate due to network failure or unavailability of the coordination component, the background recovery coroutine will not reconnect continuously at fixed short intervals, but will periodically attempt to reconnect to etcd according to a preset backoff algorithm (such as an initial wait of 1 second, with the wait time doubling after each failure, until the maximum wait limit is reached) to avoid invalid requests exhausting resources.
[0040] In some embodiments, unlike the embodiments described above, the following steps are also included: After the worker node identifier is acquired in step S2, and before the worker node identifier is used for the first time to generate the asset identifier in step S4, the following worker node identifier reuse timestamp security check step is also included: S71. Each service instance maintains the last timestamp[worker_id] of the currently occupied worker node identifier in memory, and writes the last timestamp to the distributed coordination component or the worker node identifier audit record in the database when its own service instance exits or performs a periodic heartbeat. S72. When a service instance preempts a worker node identifier, before executing the first number issuance, it reads the historical last number issuance timestamp corresponding to this worker node identifier and uses it as the historical value; S73. Compare the local current time of this service instance with the historical value: If the current local time is not greater than the historical value, wait until the current local time is greater than the historical value, or force the logical time to be set to the historical value plus one time unit, so that the new instance B uses the first numbering timestamp of the same worker node identifier. The last timestamp of the number issued is greater than that of the old instance A. .
[0041] In some embodiments, unlike the embodiments described above, the following steps are also included: After completing the storage of asset master data in step S5, the following asset query optimization and asynchronous event aggregation steps are also included: S81. When an asset code parsing request is received, the tenant identifier is obtained based on the authentication information, the cache key petro:asset:cache:{tenant_id}:{asset_code} is constructed, and the Redis cache is accessed; If the hit occurs, the asset details will be returned immediately and the access event will be recorded. If the target is not hit, proceed to step S82; S82. Based on the estimated asset quantity and target misjudgment rate Calculate the parameters of the Bloom filter and query the Bloom filter; the parameters include the bitmap length m and the number of hash functions k, which respectively satisfy;
[0042] If the Bloom filter determines that the element {tenant_id}:{asset_code} with the cache key definitely does not exist, it returns a non-existent result and does not access the database; If the Bloom filter determines that the element {tenant_id}:{asset_code} of the cache key may exist, it will query the composite unique index (tenant_id,asset_code) in the source database and fill the query result back into the Redis cache. Please see Figure 3As shown, this illustrates the complete three-level query path of an asset code parsing request after tenant authentication, sequentially involving a Redis cache query, a Bloom filter existence check, a database origin query, and result backfilling to the cache; CAS stands for atomic transaction preemption. S83. The business layer accumulates high-frequency access events into a memory map and determines the mapping key and corresponding key value; The high-frequency access events include asset queries and QR code scanner inspection events; the mapping key is tenant_id:asset_code:event_type, and the key value of the mapping key is the incremental count within the window; S84. Background flushing coroutine according to preset fixed period Perform atomic swapping: Replace the current memory mapping with an empty mapping, and perform a batch incremental update on each key in the swapped-out mapping snapshot; S85. The write amplification rejection ratio for evaluating asynchronous aggregation effects is determined using the following formula. :
[0043] in, For event arrival rate, The number of unique asset event keys within the time window; the number of database updates after asynchronous aggregation is determined by... The magnitude was reduced to Magnitude; Please see Figure 4 As shown, the process of high-frequency asset recognition events accumulating in memory mapping at the business layer, the background flushing coroutine performing atomic swapping at fixed intervals, and performing batch incremental updates on each key in the mapping snapshot, as well as the process of calling the Drain interface to force flush the buffer when the service instance gracefully exits; Taking the long-distance pipeline inspection scenario as an example, let the event arrival rate be... =1000 times / second, preset fixed period =10 seconds, number of unique asset event keys within the time window =200; then write the amplification suppression ratio. The database update frequency was reduced from 1,000 times / second to about 20 times / second; if hot assets are scanned repeatedly (e.g., a key valve chamber is scanned tens of thousands of times a day), the suppression effect is more significant. S86. When a service instance exits normally, first call the Drain interface to force flush the asynchronous event buffer, and then release the lease corresponding to the current worker node identifier according to step S61.
[0044] Taking the lifecycle management scenario of onshore oilfield equipment as an example, in a certain onshore oilfield deployment, each oil production area is treated as a tenant. After the service instance starts, it automatically preempts the worker node identifier from etcd, without manual configuration. If a well site gateway restarts due to power instability, the original worker node identifier is automatically reclaimed after the lease expires. After the gateway recovers, it re-preempts the identifier and continues to generate new device identifiers. In prototype verification, four instances concurrently generate 1 million identifiers with zero duplicate counts, while the static worker node identifier scheme exhibits approximately 9.8% conflicts due to configuration errors at the same scale.
[0045] Taking a high-frequency query optimization scenario for long-distance pipelines as an example, a pipeline company uses the method described in this application to manage equipment along the pipeline. During peak inspection periods, a three-level query path using Redis caching and Bloom filters is enabled: the cache hit rate is 92%, the Bloom filter intercepts approximately 6% of invalid queries, and only 2% return to the origin database. Asynchronous aggregation merges approximately 3000 access events per second into approximately 30 database updates per second. Actual throughput increased from 410 QPS to 8412 QPS, and P99 decreased from 1043ms to 62ms. QPS, short for Queries Per Second, is a commonly used performance metric in computer systems to measure service throughput. P99 is an abbreviation for 99th Percentile Latency, meaning that 99% of request response times are less than or equal to this value.
[0046] Taking a weak network self-healing scenario on an offshore platform as an example, a three-node etcd cluster is deployed on an offshore platform, with a lease lifetime (TTL) set to 15 seconds. When a container replica restarts, the original worker node identifier is automatically released after 15 seconds, and the new replica re-preempts it. During this period, the platform temporarily stores drilling events in a local queue. If the network is interrupted for 30 seconds and then restored, the service instance will issue a new identifier normally within the degradation window (15 seconds). After 15 seconds, the gate will be closed, and the service will automatically recover after reconnection. No manual intervention is required.
[0047] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0048] like Figure 5 As shown, the following are embodiments of the petroleum asset identification generation and self-healing management system provided in this disclosure. This system and the petroleum asset identification generation and self-healing management methods in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the petroleum asset identification generation and self-healing management system, please refer to the embodiments of the above petroleum asset identification generation and self-healing management methods.
[0049] The system includes: The tenant identifier acquisition module is used to obtain the tenant identifier of the current business. The worker node preemption module is used to apply for a lease from the distributed coordination component after the service instance starts, and to preempt an idle worker node identifier through an atomic transaction. The preempted worker node identifier is then bound to the applied lease to obtain the occupied worker node identifier and the corresponding lease identifier. The lease maintenance module is used to periodically renew leases based on lease identifiers, calculate the local valid expiration time of number issuance based on lease life and the most recent successful renewal time, and maintain the number issuance gating status based on the valid expiration time of number issuance. The identifier generation module is used to identify the numbering gating status when an asset identifier generation request is received. If the numbering gating status is allowed, the module uses the occupied work node identifier, combined with the current timestamp and sequence number, to generate a numerical asset identifier. The storage module is used to persistently store numerical asset identifiers associated with tenant identifiers, and synchronously update the Bloom filter and cache to complete the storage of asset master data. The release module is used to automatically delete the occupancy record of the corresponding bound work node identifier when the maintained lease becomes invalid due to active cancellation or expiration, so that the work node identifier can re-enter the idle pool for reuse.
[0050] This embodiment achieves secure generation and self-healing management of petroleum asset identifiers in a distributed, multi-tenant, and edge weak network environment through the interactive collaboration of the tenant identifier acquisition module, worker node preemption module, lease maintenance module, identifier generation module, storage module, and release module.
[0051] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for generating and self-healing petroleum asset identifiers, characterized in that, Includes the following steps: S1. Obtain the tenant identifier for the current service; S2. After the service instance starts, it requests a lease from the distributed coordination component, and uses an atomic transaction to preempt an idle worker node identifier. It then binds the preempted worker node identifier to the requested lease, thus obtaining the occupied worker node identifier and the corresponding lease identifier. S3. Based on the lease identifier, periodically renew the lease, calculate the local valid expiration time of number issuance according to the lease life and the most recent successful renewal time, and maintain the number issuance gating status according to the valid expiration time of number issuance; S4. When an asset identifier generation request is received, identify the numbering gating status. If the numbering gating status is allowed, use the occupied work node identifier, combined with the current timestamp and sequence number to generate a numerical asset identifier. S5. After associating the numerical asset identifier with the tenant identifier, persist the data and update the Bloom filter and cache simultaneously to complete the storage of the asset master data; S6. When a maintained lease becomes invalid due to active cancellation or expiration, the occupancy record of the corresponding bound work node identifier is automatically deleted, so that this work node identifier re-enters the idle pool for reuse.
2. The method for generating and self-healing petroleum asset identifiers according to claim 1, characterized in that, The specific steps of step S1 are as follows: S11. Assign a unique tenant identifier to each logical organization managing petroleum assets and carry the tenant identifier in an authentication token, API request header, or edge gateway certificate. The logical organization includes oil and gas field companies, oil production plants, operating areas, pipeline companies, or offshore platforms. S12. Establish an asset master table in the database. The asset master table shall at least include primary key, tenant identifier, asset identifier code, asset type and lifecycle status fields, and establish a combined unique index on the tenant identifier and asset identifier code. S13. Based on the aforementioned composite unique index, define the cache namespace, Bloom filter storage elements, and asynchronous event aggregation keys to ensure that tenant boundaries remain consistent across the database, cache, filter, and statistics chain. S14. Load configuration parameters when the service starts. The configuration parameters include worker node identifier pool size, lease lifetime (TTL), safety margin (M), Snowflake epoch start time, Redis address, Bloom filter target false positive rate, and event aggregation flushing cycle.
3. The method for generating and self-healing petroleum asset identifiers according to claim 1, characterized in that, The specific steps of step S2 are as follows: S21. Let the bit width of the working node identifier be... Then the candidate working node identifier The range of values is ,in It is a preset positive integer; S22. Identify each candidate working node. In the distributed coordination component, an occupancy key is defined. If the occupancy key exists, it means that the corresponding worker node identifier has been occupied. If the occupancy key does not exist, it means that the corresponding worker node identifier is idle. S23. After the service instance starts, it sends a lease request carrying the lease lifetime to the distributed coordination component and obtains a lease identifier; S24. The service instance iterates through the candidate worker node identifier set, and for each candidate worker node identifier... Perform a compare and write operation based on a distributed coordination component transaction: Check if the occupancy key corresponding to this candidate worker node identifier does not exist; If it does not exist, the metadata of the current service instance will be written to this occupancy key, and the occupancy key will be bound to the applied lease, thereby granting the current service instance exclusive use of the current candidate worker node identifier; If it already exists, continue trying the next candidate worker node identifier; S25. After successfully preempting the worker node identifier, the service instance constructs a lease snapshot locally and publishes the lease snapshot to the number issuer in an atomic manner. The lease snapshot includes at least the fields of worker node identifier, lease identifier, lease lifetime, most recent successful renewal time, valid expiration time of number issuance, number issuance gating status, and lease version number.
4. The method for generating and self-healing petroleum asset identifiers according to claim 3, characterized in that, The specific steps of step S3 are as follows: S31. After successfully preempting the worker node identifier, start the lease maintenance coroutine and send renewal requests to the distributed coordination component at a preset ratio of the lease life. S32. Whenever a successful response to a lease renewal request is received, record the response arrival time to update the most recent successful lease renewal time in the lease snapshot, and calculate the local valid expiration time of the number issuance according to the following formula: ; in, This is the valid deadline for issuing numbers. This is the latest time that the lease renewal was successfully completed. M is the lease lifetime, M is the safety margin, and satisfies... , This represents the upper bound of the deviation between the local clock and the coordinated time. This is an estimate of the maximum acceptable network or processing latency. S33. The lease maintenance coroutine sets the number gating status to true and updates the local lease snapshot; S34. Monitor the execution result of the renewal request, and perform the following processing based on the comparison between the current local time and the valid expiration time of the number issuance: If a renewal request fails momentarily but the current local time has not exceeded the valid expiration time for issuing new numbers, the service instance enters the lease lifetime degradation window, allowing the issuance of new numbers and continuous retrying of renewal requests. If the current local time reaches or exceeds the valid deadline for issuing numbers, the number issuance gating status will be set to false, and any subsequent number issuance request will return a "not allowed" error. S35. If the distributed coordination component returns an unrecoverable error, the service instance closes the number issuance gate and triggers a re-preemption process; the unrecoverable error includes lease revocation, lease non-existence, or authentication failure.
5. The method for generating and self-healing petroleum asset identifiers according to claim 3, characterized in that, The specific steps of step S4 are as follows: S41. After receiving the asset identifier generation request, the business layer of the service instance performs tenant authentication based on the tenant identifier obtained in step S1; the asset identifier generation request includes asset registration, asset tag binding or digital twin object creation request; S42. The number generator obtains a local lease snapshot, checks whether the number generation gating status is allowed and whether the current time is less than the valid expiration time for number generation; If so, proceed to step S43; If not, refuse to generate asset identifiers and return an error; S43. Number dispenser reads monotonic millisecond time. And calculate the numerical asset identifier according to the following formula. : in, The preset start time of the era. The bit width for the worker node identifier. For the same millisecond sequence number width, The worker node identifier held by the current instance. An incrementing sequence number within the same millisecond; S44. If the sequence number is incremented within the same millisecond... Achieving the same millisecond sequence number bit width The maximum allowed value The serial number generator will wait until the next millisecond and reset the serial number incremented within the same millisecond. =0; S45. If a local time rollback is detected and the rollback magnitude exceeds a preset threshold, the number issuance gate is closed and the current lease is released, triggering the process of re-seizing the work node identifier. The callback refers to the local time being reversed compared to the time of the most recent number issuance; S46. The generated numerical asset identifier is Base62 encoded into an external asset identifier code.
6. The method for generating and self-healing petroleum asset identifiers according to claim 1, characterized in that, The specific steps of step S5 are as follows: S51. Associate the numerical asset identifier with the tenant identifier to generate an asset master data record. The asset master data record also includes the asset type, physical location, equipment manufacturer, commissioning date, lifecycle status, and digital twin object address. S52. Write the asset master data into the persistent asset master table and use a composite unique index to ensure the uniqueness of the tenant identifier; S53. Insert the element formed by concatenating the tenant identifier and the external asset identifier into a Bloom filter; S54. Create a cache key based on a composite unique index, write asset details to the Redis cache, and set the cache expiration time; S55. Output the asset identifier generation event to the asynchronous event aggregator.
7. The method for generating and self-healing petroleum asset identifiers according to claim 1, characterized in that, The specific steps of step S6 are as follows: S61. When a service instance exits normally, causing the lease to expire, stop receiving new requests, flush the asynchronous event buffer, call the lease cancellation interface to actively release the lease, and delete the occupied key identified by the corresponding worker node; S62. When a service instance crashes, the host machine goes down, or the network is interrupted for more than a preset time, causing the lease to expire, the service instance stops sending renewal requests, and the distributed coordination component automatically deletes the occupied key of the corresponding worker node after the lease life expires. S63. After the occupancy key is deleted, the corresponding worker node identifier will automatically enter the idle pool, and the remaining normal running service instances will be preempted and reused in the future; S64. After the number issuance gate is closed due to a fault, the background recovery coroutine reconnects to the distributed coordination component according to the backoff strategy, and after the connection is restored, it first confirms whether the original lease is still valid. If effective, restore the renewal request and number issuance gating status, and return to step S3; If this is ineffective, the worker node identifier preemption process in step S2 will be re-executed.
8. The method for generating and self-healing petroleum asset identifiers according to claim 1, characterized in that, After the worker node identifier is acquired in step S2, and before the worker node identifier is used for the first time to generate the asset identifier in step S4, the following worker node identifier reuse timestamp security check step is also included: S71. Each service instance maintains the last issuance timestamp of the currently occupied worker node identifier in memory, and writes the last issuance timestamp to the distributed coordination component or the worker node identifier audit record in the database when its own service instance exits or periodically heartbeats. S72. When a service instance preempts a worker node identifier, before executing the first number issuance, it reads the historical last number issuance timestamp corresponding to this worker node identifier and uses it as the historical value; S73. Compare the local current time of this service instance with the historical value: If the current local time is not greater than the historical value, wait until the current local time is greater than the historical value, or force the logical time to be set to the historical value plus one time unit, so that the new instance B uses the first numbering timestamp of the same worker node identifier. The last timestamp of the number issued is greater than that of the old instance A. .
9. The method for generating and self-healing petroleum asset identifiers according to claim 1, characterized in that, After completing the storage of asset master data in step S5, the following asset query optimization and asynchronous event aggregation steps are also included: S81. When an asset code parsing request is received, the tenant identifier is obtained based on the authentication information, a cache is constructed, and the Redis cache is accessed; If the hit occurs, the asset details will be returned immediately and the access event will be recorded. If the target is not hit, proceed to step S82; S82. Based on the estimated asset quantity and target misjudgment rate Calculate the parameters of the Bloom filter and query the Bloom filter; the parameters include the bitmap length m and the number of hash functions k, which respectively satisfy; If the Bloom filter determines that the element with the cache key definitely does not exist, it returns a non-existent result and does not access the database; If the Bloom filter determines that the element with the cache key may exist, it queries the composite unique index in the source database and fills the query result back into the Redis cache. S83. The business layer accumulates high-frequency access events into a memory map and determines the mapping key and corresponding key value; The high-frequency access events include asset queries and QR code scanner inspection events; S84. Background flushing coroutine according to preset fixed period Perform atomic swapping: Replace the current memory mapping with an empty mapping, and perform a batch incremental update on each key in the swapped-out mapping snapshot; S85. The write amplification rejection ratio for evaluating asynchronous aggregation effects is determined using the following formula. : in, For event arrival rate, The number of unique asset event keys within the time window; the number of database updates after asynchronous aggregation is determined by... The magnitude was reduced to Magnitude; S86. When a service instance exits normally, first call the Drain interface to force flush the asynchronous event buffer, and then release the lease corresponding to the current worker node identifier according to step S61.
10. A petroleum asset identification generation and self-healing management system, characterized in that, include: The tenant identifier acquisition module is used to obtain the tenant identifier of the current business. The worker node preemption module is used to apply for a lease from the distributed coordination component after the service instance starts, and to preempt an idle worker node identifier through an atomic transaction. The preempted worker node identifier is then bound to the applied lease to obtain the occupied worker node identifier and the corresponding lease identifier. The lease maintenance module is used to periodically renew leases based on lease identifiers, calculate the local valid expiration time of number issuance based on lease life and the most recent successful renewal time, and maintain the number issuance gating status based on the valid expiration time of number issuance. The identifier generation module is used to identify the numbering gating status when an asset identifier generation request is received. If the numbering gating status is allowed, the module uses the occupied work node identifier, combined with the current timestamp and sequence number, to generate a numerical asset identifier. The storage module is used to persistently store numerical asset identifiers associated with tenant identifiers, and synchronously update the Bloom filter and cache to complete the storage of asset master data. The release module is used to automatically delete the occupancy record of the corresponding bound work node identifier when the maintained lease becomes invalid due to active cancellation or expiration, so that the work node identifier can re-enter the idle pool for reuse.